<table cellpadding="0" cellspacing="0">
	<tbody>
        <tr>
            <td class="leftside">
           		<?php require_once("menu.php");?>
            </td>
            <td class="rightside">
                <div class="box" style="margin-left:10px; margin-right: 10px; float:left;">
                	<div id='title_menu' class="ui-corner-top">Banners Management</div>  
                    <div class="content" style="min-height: 150px;">
                    <?php
						$sql = 'SELECT
								  `positions`.`position_name`, `category`.`cat_name`, `banners`.*
								FROM
								  `banners` INNER JOIN
								  `category` ON `category`.`cat_id` = `banners`.`cat_id` INNER JOIN
								  `positions` ON `banners`.`position_id` = `positions`.`id`';
						$q = $db->select_query($sql);		
						$count = $db->rows($q);				
					?>
                    <form action="#" method="post" id="banner-form">
                    <p>Version 1 ยังไม่สามารถแยกหมวดการลงประกาศได้</p>
                	  <table class="list">
                        <thead>
                          <tr align="center">
                            <td>ลำดับ</td>
                            <td>รหัสแบนเนอร์</td>
                            <td>สถานะ</td>
                            <td>หมวดหมู่</td>
                            <td>ตำแหน่ง</td>
                            <td>ระยะเวลาลงประกาศ</td>
                            <td>สิ้นสุดประกาศ</td>
                            <td>ลบประกาศ</td>
                          </tr>
                        </thead>
                        <tbody>
                       	<?php
						$i = 1;
						while($rs = $db->fetch($q)){
						?>      
                          <tr align="center">
                          	<td><?php echo $i;?></td>
                            <td><?php echo $rs['banner_id'];?></td>
                            <td>
                            	<select name="status" id="status" bid="<?php echo $rs['banner_id'];?>">
                                    <option value="0" <?php ($rs['active']==0)? print 'selected="selected"':'';?>>Pending</option>
                                    <option value="1" <?php ($rs['active']==1)? print 'selected="selected"':'';?>>Active</option>
                                    <option value="2" <?php ($rs['active']==2)? print 'selected="selected"':'';?>>Expire</option>
                                </select>
                            </td>
                            <td><?php ($rs['cat_name']=='')?print 'ทุกหมวด':print $rs['cat_name'];?></td>
                            <td><?php echo $rs['position_name'];?></td>
                            <td>
                            	<select name="period" id="period" bid="<?php echo $rs['banner_id'];?>">
                                    <option value="1" <?php ($rs['period']==1)? print 'selected="selected"':'';?>>1 Month</option>
                                    <option value="6" <?php ($rs['period']==6)? print 'selected="selected"':'';?>>6 Months</option>
                                    <option value="12" <?php ($rs['period']==12)? print 'selected="selected"':'';?>>12 Months</option>
                                </select>
                            </td>
                            <td><?php echo ThaiTimeConvert($rs['banner_expire'],0,0);?></td>
                            <td>
                            	<a href="#" bid="<?php echo $rs['banner_id'];?>" id="del_banner">
                                	<img src="images/delete.png" title="Delete this banner" />
                                </a>
                            </td>
                          </tr>
                        <?php $i++; }?>  
                        <?php if(empty($count)){?>
                          <tr>
                          	<td colspan="8">
                            	<div style="color: #0369C0; font-size: 18px; font-weight: bold; padding: 10px; text-align: center;">ยังไม่มีรายการประกาศแบนเนอร์</div>
                            </td>
                          </tr>
                        <?php }?> 
                        </tbody>
                      </table>
                   	</form>
                    </div>
                </div>            
            </td>
        </tr>
   	</tbody>
</table>